home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #14
/
Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO
/
prog_d
/
oleauttr.zip
/
OLEAUTO.INT
< prev
next >
Wrap
Text File
|
1996-01-04
|
10KB
|
205 lines
{
// OLEAUTO.INT (C) 1995 W. Raike
// ALL RIGHTS RESERVED.
// NOTICE: This file consists of trade secrets that are the property
// of William Raike. The contents may not be used or disclosed
// without express written permission of the owner.
NOTE: The information in this file is for information only and
is subject to change.
}
{
****************************************************************
Here are the most important sections of the public interface for
the Delphi classes contained in the module OLEAUTO.DCU :
****************************************************************
}
interface
uses
Classes, SysUtils;
const
MAXARGS = 64; { Max. no. of arguments to a method. }
type
DWORD = longint;
ULONG = DWORD;
HRESULT = Pointer;
ppV = ^Pointer; { Pointer to pointer }
pPChar = ^PChar; { Pointer to PChar }
pBYTE = ^Byte; { Pointer to Byte }
pInt = ^Integer; { Pointer to Integer }
pWORD = ^WORD; { Pointer to WORD }
pDWORD = ^DWORD; { Pointer to DWORD }
pSingle = ^Single; { Pointer to Single }
pDouble = ^Double; { Pointer to Double }
ODATE = Double;
pODATE = ^ODATE;
VARIANT_BOOL = Integer;
pVARIANT_BOOL = ^VARIANT_BOOL;
CY = record { helper structure for currency }
Lo : DWORD;
Hi : DWORD;
end;
pCY = ^CY;
S_OK = HRESULT(nil);
{ OLE error codes - defined in SCODE.H - Values for OleAutoErrCode property.}
E_UNEXPECTED = HRESULT($8002FFFF); {relatively catastrophic failure}
E_NOTIMPL = HRESULT($80020001); {not implemented}
E_OUTOFMEMORY = HRESULT($80020002); {ran out of memory}
E_INVALIDARG = HRESULT($80020003); {one or more args are invalid}
E_NOINTERFACE = HRESULT($80020004); {no such interface supported}
{ The following OleAutoErrCode usually results when the number or types
of arguments passed to a method/property call are not correct. }
E_POINTER = HRESULT($80020005); {invalid pointer}
{ The following OleAutoErrCode usually results when the name
or type specified for CallOleProc or CallOleFunction is not correct. }
E_HANDLE = HRESULT($80020006); {invalid handle}
E_ABORT = HRESULT($80020007); {operation aborted}
E_FAIL = HRESULT($80020008); {unspecified error}
E_ACCESSDENIED = HRESULT($80020009); {general access denied error}
{ Exception classes specific to TOleAutomationClient component: }
type
EOleAutoNoCreate = class(Exception);
EOleAutoOutOfMemory = class(EOutOfMemory);
EOleAutoInvokeFailure = class(Exception);
{ Public non-member functions. }
procedure OleEnable; { Called by TOleAutomationClient component constructor }
procedure OleDisable; { Called by TOleAutomationClient component destructor }
{ Parent class from which to derive a "mirror" class that reflects the
properties/methods of the OLE Automation server you want to control. }
type
TOleObject = class
protected
function GetPDisp : pIDisp; { Not normally used in derived classes. }
function GetRefCount : Integer; { Not normally used in derived classes. }
{ Call the following function after a call to any of the other
member functions in this class to determine whether an error
occurred. It returns True if an error occurred, False otherwise. }
function GetOleAutoFailFlag : Boolean;
{ See descriptions below to see how to use the following functions. }
procedure SetOleMethodArg(sParamType : String; var ActualParam); virtual;
procedure CallOleFunction(sMethodName : String; sReturnType : String; var Retval); virtual;
procedure CallOleProc(sMethodName : String); virtual;
procedure SetOleProperty(sPropertyName : String; sPropertyType : String; var PropVal); virtual;
procedure GetOleProperty(sPropertyName : String; sPropertyType : String; var RetVal); virtual;
{ The following properties contain error status information
pertaining to the most recent OLE method call and/or property access.}
property OleAutoFailFlag : Boolean;
{ See the above OLE error code definitions for the possible values of
the following property. E.g., S_OK, E_HANDLE, etc. }
property OleAutoErrCode : HRESULT;
public
{ Create when a pdisp is already available (i.e., for a nested object. }
constructor ConnectInterface(pdisp : PInterface); virtual;
{ Create from scratch using an in-process server (.DLL server). }
constructor CreateInProcessObject(prgid : String); virtual;
{ Create from scratch using a local server (.EXE server),
or, if that fails, an in-process (16-bit DLL) server. }
constructor CreateObject(prgid : String); virtual;
{ Get access to an already-running instance of an OLE auto server. }
constructor GetObject(prgid : String); virtual;
destructor Release ; virtual;
end;
{ This module calls external functions in DLLs that should be in
\WINDOWS\SYSTEM. The required DLLs are OLE2.DLL and OLE2DISP.DLL,
and functions in these (Microsoft-supplied) DLLs may in turn call
functions in others such as COMPOBJ.DLL, MSOLE2.DLL, OLE2REG.DLL,
OLE2NLS.DLL and possibly others. }
{
****************************************************************
Here are explanations of the parameters to the class methods:
****************************************************************
}
{
In a class derived from TOleObject, in the implementation of each method corresponding
to an OLE method to be invoked, call SetOleMethodArg once for each argument to be passed.
The order in which these calls are made will specify the order in which the arguments are
to be passed to the OLE method by the CallOleFunction or CallOleProc methods.
***NOTE***: These calls must be in REVERSE ORDER of the actual argument order!!(I.e.,R->L!)
The sParamType parameter should be one of the following : (case is not significant)
'Boolean' | 'Integer' | 'Longint' | 'Word' | 'Byte' | 'Char' | 'Single ' | 'Double' |
'PChar' | 'PInterface' | 'Pointer' | 'ODate' | 'OCurrency' | 'VariantRef'
*Note: 'PInterface' refers to the pIDisp type defined in the OLETypes unit.
and is used to access "nested" OLE objects.
'ODate' and 'OCurrency' refer to OLE date and currency types (see OLETYPES.PAS).
'VariantRef' refers to the OLE VARIANT type and can only be passed by reference.
Optionally, these may be prefixed by the symbol '&' to indicate that the argument is to
be passed by reference, analogous to a var parameter in Pascal. Note, however, that
PChar itself passes null-terminated strings by reference.
}
procedure TOleObject.SetOleMethodArg(sParamType : String; var ActualParam);
{
In a class derived from TOleObject, in the implementation of each method corresponding
to an OLE method to be invoked, a call to CallOleFunction causes the OLE automation object
to execute the desired method with parameters determined by the preceding sequence of
calls to SetOleMethodArg.
The return types are the same as those specified for SetOleMethodArg,
except that they may be preceded by a ^ symbol to indicate that the return value
is a pointer to the specified type. The actual return value is placed in the
RetVal argument.
To call methods that don't return a value, use CallOleProc instead. }
}
procedure TOleObject.CallOleFunction(sMethodName : String; sReturnType : String; var RetVal);
{
Like CallOleFunction, but without any return type.
}
procedure TOleObject.CallOleProc(sMethodName : String);
{
In a class derived from TOleObject, in the implementation of each method corresponding
to an OLE property to be set, call SetOleProperty once with the property's name,
type and value.
The sPropertyType parameter should be one of the following : (case is not significant)
'Boolean' | 'Integer' | 'Longint' | 'Word' | 'Byte' | 'Char' | 'Single ' | 'Double' |
'PChar' | 'PInterface' | 'Pointer' | 'ODate' | 'OCurrency' | 'VariantRef'
*Note: 'PInterface' refers to the pIDisp type defined in the OLETypes unit.
and is used to access "nested" OLE objects.
'ODate' and 'OCurrency' refer to OLE date and currency types (see OLETYPES.PAS).
'VariantRef' refers to the OLE VARIANT type and can only be passed by reference.
Optionally, these may be prefixed by the symbol '&' to indicate that
the property value is to be passed by reference, analogous to a var parameter in Pascal.
This will normally be used only when passing a reference to an OLE object.
}
procedure TOleObject.SetOleProperty(sPropertyName : String;
sPropertyType : String; var PropVal);
{
In a class derived from TOleObject, in the implementation of each method corresponding
to an OLE property to be retrieved, call GetOleProperty once with the property's name
and type.
The sPropertyType parameter should be one of the following : (case is not significant)
'Boolean' | 'Integer' | 'Longint' | 'Word' | 'Byte' | 'Char' | 'Single ' | 'Double' |
'PChar' | 'PInterface' | 'Pointer' | 'ODate' | 'OCurrency' | 'VariantRef'
*Note: 'PInterface' refers to the pIDisp type defined in the OLETypes unit.
and is used to access "nested" OLE objects.
'ODate' and 'OCurrency' refer to OLE date and currency types (see OLETYPES.PAS).
'VariantRef' refers to the OLE VARIANT type and can only be retrieved via
a pointer.
Optionally, these (except for VariantRef) may be prefixed by the symbol '&' to indicate
that a pointer to a pointer to the property value is to be retrieved, rather than
simply a pointer to the value.
}
procedure TOleObject.GetOleProperty(sPropertyName : String;
sPropertyType : String; var RetVal);
implementation